home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr35 / sbbsvol1.zip / EXEC.ZIP / SBBSQNET.SLT < prev    next >
Text File  |  1993-06-02  |  3KB  |  124 lines

  1.  
  2. //    Logon to Synchronet and transfer QWK packets using Zmodem
  3. //    The 'login name' node account must have the 'Q' restriction set on
  4. //    the hub (call-out to) system.
  5. //    arg1=system id
  6. //    arg2=dial list
  7. //    arg3=login name
  8. //    arg4=password
  9. //    arg5=retry count
  10.  
  11. main(str arg1, str arg2, str arg3, str arg4, str arg5)
  12. {
  13.     str path[128],tmp[128];
  14.     int t,tmark,tstat,nn,pw,pause,qwk,prot,qwkcnt=0;
  15.  
  16. clear_scr();
  17. printsc("SBBSQNET: Initialized ");
  18. t=curtime();
  19. date(t,tmp);
  20. printsc(tmp);
  21. printsc(" ");
  22. time(t,tmp);
  23. prints(tmp);
  24.  
  25. copystr(_up_dir,path,0,80);
  26. strcat(path,"\");
  27. strcat(path,arg1);
  28. strcat(path,".LOG");
  29. printsc("SBBSQNET: ");
  30. if(usagelog(path)==-1)
  31.     printsc("ERROR OPENING ");
  32. else
  33.     printsc("Opened ");
  34. prints(path);
  35.  
  36. copystr(_up_dir,path,0,80);
  37. strcat(path,"\");
  38. strcat(path,arg1);
  39. strcat(path,".REP");
  40.  
  41. if(filesize(path)>0) {
  42.     printsc("SBBSQNET: Attempting to send ");
  43.     prints(path); }
  44.  
  45. printsc("SBBSQNET: ");
  46. copystr("Calling ",tmp,0,80);
  47. strcat(tmp,arg1);
  48. prints(tmp);
  49. ustamp(tmp,1,1);
  50.  
  51. printsc("SBBSQNET: Dialing ");
  52. prints(arg2);
  53. if(redial(arg2,stoi(arg5),1)==-1)    // Dialing error
  54.     return;
  55.  
  56. nn=track("NN:",0);
  57. pw=track("PW:",0);
  58. qwk=track("QWK:",0);
  59. prot=track("PROTOCOL OR QUIT",1);
  60. pause=track("HIT A KEY",1);
  61.  
  62. tmark=timer_start(60000);        // wait up to 10 minutes for sucess
  63. while(not time_up(tmark)) {
  64.     if(not carrier()) {
  65.         ustamp("No carrier.",1,1);
  66.         break; }
  67.     terminal();
  68.     tstat=track_hit(0);        // check for track hit
  69.  
  70.     if(tstat==nn) {         // NN: prompt
  71.         delay(1);
  72.         cputs("^X");            // clear any garbage
  73.         cputs(arg3);        // send login name
  74.         cputs("^M"); }
  75.  
  76.     else if(tstat==pw) {        // PW: prompt
  77.         delay(1);
  78.         cputs(arg4);        // send password
  79.         cputs("^M"); }
  80.  
  81.     else if(tstat==pause)        // Hit a key
  82.         cputs("^M");
  83.  
  84.     else if(tstat==qwk) {        // QWK prompt
  85.         delay(1);
  86.         qwkcnt=qwkcnt+1;
  87.         if(qwkcnt==1) {
  88.             if(filesize(path)>0) {
  89.                 cputs("UZN");
  90.                 terminal();
  91.                 if(send('Z',path)>=0) {         // successful
  92.                     copystr("DEL ",tmp,0,4);
  93.                     strcat(tmp,path);
  94.                     dos(tmp,0); } }     // delete REP
  95.             else qwkcnt=2; }
  96.         if(qwkcnt==2) {
  97.             cputs("DL");
  98.             while(not time_up(tmark)) {
  99.                 if(not carrier())
  100.                     break;
  101.                 terminal();
  102.                 tstat=track_hit(0);
  103.                 if(tstat==qwk) {
  104.                     qwkcnt=3;
  105.                     break; }
  106.                 if(tstat==prot) {
  107.                     cputs("ZN");
  108.                     terminal();
  109.                     receive('Z',"");
  110.                     break; } } }
  111.         if(qwkcnt==3) {
  112.             cputs("Q");
  113.             break; } } }
  114. terminal();
  115. if(time_up(tmark)) {
  116.     prints("SBBSQNET: Timeout.");
  117.     ustamp("Timeout.",1,1); }
  118. hangup();
  119. timer_free(tmark);        // free timer channel
  120. track_free(0);            // free track channels
  121. usagelog("*CLOSE*");            // close log file
  122. }
  123.  
  124.